package com.fastjrun.util;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Stan
 */
public abstract class AbstractIpUtil implements IpUtil {
    /**
     * 根据域名获取IP地址
     *
     * @param domain 域名
     * @return 域名解析出来的IP地址
     */
    public String getIpByDomain(String domain) {
        try {
            InetAddress myServer = InetAddress.getByName(domain);
            return myServer.getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return "";
    }

}
